﻿#region
/*******************************************************************************
** File Name:		    ProductRepository.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using Phoenix.Entity;
using Phoenix.Respository;
using IBatisNet.DataMapper;
using Phoenix.Data.IBatis;
using System.Collections;

namespace Phoenix.IBatisRepository
{
    public class ProductRepository : BaseIBatisDao,IProduct
    {
    
		#region  Auto Generation

        public ProductRepository()
            : base("/Config/IBatis/86TCMap.Config")
        {

        }
        		
        public void AddProduct(EProduct entity)
        {
			string stmtId = "ProductMap.InsertProduct";
			base.SqlMapper.Insert(stmtId, entity);
        }
        
		public  EProduct GetByProductID (System.Int32 productID)
        {
			string stmtId = "ProductMap.SelectByProductID";
			return base.SqlMapper.QueryForObject<EProduct>(stmtId, productID);
        }
        
        public  void DeleteByProductID (System.Int32 productID)
        {
			string stmtId = "ProductMap.DeleteByProductID";
			base.SqlMapper.Update(stmtId, productID);
        }
        
        public  void UpdateByProductID (EProduct entity)
        {
			string stmtId = "ProductMap.UpdateByProductID";
			base.SqlMapper.Update(stmtId, entity);
        }


		public  IList<EProduct> GetAll ()
        {
			string stmtId = "ProductMap.SelectAll";
			return base.SqlMapper.QueryForList<EProduct>(stmtId,null);
        }

		#endregion

        public void UpdateTaoKe(int productID, bool taoKe)
        {
            string stmtId = "ProductMap.UpdateTaoKe";
            Hashtable ht = new Hashtable();
            ht.Add("ProductID", productID);
            ht.Add("TaoKe", taoKe);

            base.SqlMapper.Insert(stmtId, ht);

        }
    }
}

